let myVue = new Vue({
    el:"#main",
    data:{
        pageInfo:{},
    },
    methods: {
        selectPage: function (pageNum, pageSize) {
            axios({
                url: `role/selectPage/${pageNum}/${pageSize}`
            }).then(response => {
                this.pageInfo = response.data.obj;
                let roles = this.pageInfo.list;
                for (let i in roles) {
                    let privilege = roles[i].privileges;
                    // console.log(privilege);
                    let rp = '';
                    //遍历权限，连成一个字符串
                    for(let j in privilege){
                        rp += privilege[j].privilegeName;
                        rp += "、";
                        //判断是不是最后一个权限
                        if(j == privilege.length - 1){
                            rp = rp.substring(0, rp.lastIndexOf('、'));
                            // console.log(rp);
                        }
                    }
                    roles[i].privileges = rp;
                }
            });
        },
        toInsert:function () {
            window.location='html/role/role_add.html'
        },
        // toDetail:function (id) {
        //     layer.obj = id; //绑定id到index窗口对象layer中
        //     layer.message = '';
        //     layer.open(
        //         {
        //             type: 2, //iframe
        //             title: '详情页面',
        //             area: ['80%', '90%'],
        //             content: 'admin/toDetail'
        //         }
        //     )
        // }
    },
    //初始化
    created:function () {
        this.selectPage(1,5);
    }
});